%%%-------------------------------------------------------------------
%%% File    : svc_queue_sup.erl
%%% Author  :  <vjache>
%%% Description : Supervisor for all queues. Each queue is an instance 
%%%				  of 'svc_queue' with registered name same as queue 
%%%				  name hence queue name is an atom.
%%%
%%% Created : 24 Jun 2009 by  <vjache>
%%%-------------------------------------------------------------------
-module(svc_queue_sup).

-behaviour(supervisor).

%% API
-export([start_link/1]).

%% Supervisor callbacks
-export([init/1]).

-define(SERVER, dmtr_queues).

%%====================================================================
%% API functions
%%====================================================================
%%--------------------------------------------------------------------
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
%% Description: Starts the supervisor
%%--------------------------------------------------------------------
start_link(QueueConfigList) ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, [QueueConfigList]).

%%====================================================================
%% Supervisor callbacks
%%====================================================================
%%--------------------------------------------------------------------
%% Func: init(Args) -> {ok,  {SupFlags,  [ChildSpec]}} |
%%                     ignore                          |
%%                     {error, Reason}
%% Description: Whenever a supervisor is started using 
%% supervisor:start_link/[2,3], this function is called by the new process 
%% to find out about restart strategy, maximum restart frequency and child 
%% specifications.
%%--------------------------------------------------------------------
init([QueueConfigList]) ->
    AQueues = [
			   {_QName=element(1,QueueConfig),
				{svc_queue,start_link,[QueueConfig]},
				permanent,
				2000,
				worker,
				[svc_queue]
			   }||QueueConfig<-QueueConfigList],
    {ok,{{one_for_one,0,1}, AQueues}}.

%%====================================================================
%% Internal functions
%%====================================================================


